<!--
 * @Author: your name
 * @Date: 2022-03-17 19:20:10
 * @LastEditTime: 2022-03-18 09:42:14
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \geyao\geyao\slice220317.html
-->
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>slice</title>
</head>
<body>
  <script>
    var fangfang=["geyao","fangfang","huahua","mingming"]
    //arr.slice([begin[, end]])
    var fangfangTest=fangfang.slice(1)
    //从第一位进行截取
    console.log(fangfangTest,"fangfangTest") // [ "fangfang", "huahua", "mingming" ]
    //截取数组的二到四位
    var fangfangList=fangfang.slice(2,4)
    console.log(fangfangList,"fangfangList") //[  "huahua", "mingming" ]
    //截取数组的第一位到倒数第二个元素
    var fangfangHH=fangfang.slice(1,-1)
    console.log(fangfangHH,"fangfangHH") //[ "fangfang","huahua"]

  </script>
</body>
</html>